import sys
sys.path.append('..')

from models import db, Jobnumber

with open('jobnumbers.csv','r') as f:
    lines = f.readlines()

for line in lines:
    line = line.strip()
    if(line):
        name,desc = line.split(',')
        name = name.strip()
        desc = desc.strip()
        if Jobnumber.query.filter_by(name=name).first():
            print(f'{name} exist')
        else:
            db.session.add(Jobnumber(name=name,desc=desc))
            db.session.commit()
            print(f'Add {name} Successfully!')


